INCLUDE = `pkg-config --cflags glib-2.0`
LDFLAGS = `pkg-config --libs glib-2.0`

# Development flags
CFLAGS = -std=c99 -Wall -g -O0 $(INCLUDE)
# Production flags
# CFLAGS = -std=c99 -march=i486 -mtune=i686 -O2 -pipe

OBJS = addr.o main.o common.o msg.o net.o node.o ui.o file.o proto.o search.o
TESTS = test_addr test_common 
BINS = node
.PHONY: clean tests

all: $(BINS) $(TESTS)
node: $(OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o node
addr.o: addr.h common.h
tests: $(TESTS)
	@echo "Running all tests: $(TESTS)"
	@echo "Done"
test_%: test_%.c %.o
	$(CC) $(CFLAGS) $^ -o $@
test_msg: addr.o
test_addr: common.o
clean:
	rm -rf $(BINS) $(OBJS) $(TESTS)
